2.1:
Getting the Microsoft Agent control
To
get the Microsoft Agent control, click on the Tools toolbar and select
Customize Toolbox. Once you are in the Customize
Toolbox dialog, select the COM Components tab, and choose the Microsoft Agent
Control 2.0. Put the Microsoft Agent
control on the form and change its Name property to agtAgent.
2.2:
Loading a character and showing it
To
load a character add this code into your Form_Load section.
Dim Character As AgentObjects.IAgentCtlCharacter
Dim sChar As String
On Error
GoTo handler
' The path to the character file
sChar = "C:\Windows\msagent\chars\genie.acs"
' Load the character
agtAgent.Characters.Load("CharacterID", sChar)
' Set the "Character"
declaration to be the character just loaded
Character = agtAgent.Characters("CharacterID")
' Set the character's language to
english
Character.LanguageID = &H409
' Show the character
Character.Show()
Exit Sub
handler:
If Err.Number <> 0 Then MessageBox.Show("Description: " &
_
Err.Description, "Error!", MessageBoxButtons.OK, _
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
Err.Clear()
Exit Sub
2.3: Getting a character’s
information
To get a character’s name,
description, and extra data, add this to your code:
Dim sName, sDescription,
sExtraData As String
sName = Character.Name ' Character's
Name property
sDescription = Character.Description '
Character's Description
sExtraData = Character.ExtraData ' Character's ExtraData
2.4: Getting the names of
the character’s animations
This part uses a ComboBox
with the Name cboCombo.
To get the names of the
character’s animations, add this to your code:
Dim animationName
' Clear the ComboBox
cboCombo.Items.Clear()
' Load each animation the currently
selected character
' has into the ComboBox
For Each
animationName In Character.AnimationNames
cboCombo.Items.Add(animationName)
Next
2.5: Hiding a character
To hide a character, add this
to your code.
Character.Hide()